home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-06-26 | 1.1 KB | 48 lines | [TEXT/GEOL] |
- Item 2290855 16-May-89 16:25
-
- From: PASCOE1 Pascoe, Geoff
-
- To: MACAPP.TECH$ MACAPP Tech
-
- Sub: Re to Specializing fields
-
- Alan, Howard, and Joel-
-
- I think changing the names of instance variables like this is probably not
- such a great idea. I agree with Howard that this can make reading code really
- hard. However, Trellis allows you to redeclare an instance variable in
- a subclass as long as that variable conforms to the superclass type (i.e.,
- is a subclass of it. For example,
-
- TA = OBJECT(TObject)
- :
- :
- END;
-
- TB = OBJECT(TA)
- :
- :
- END;
-
- TC = OBJECT(TObject)
- fInstVar : TA;
- :
- :
- END;
-
- TD = OBJECT(TC)
- fInstVar : TB;
- :
- :
- END;
-
- Since TB conforms to TA because it is a subclass of TA, we can redeclare it
- to be more specialized when it is an instance variable.
-
- Unfortunately you can't do this in Object Pascal or C++. Typically,
- programmers will either create another, parallel, instance variable of
- the proper type or cast it when it's is used in the more specialized way.
-
- Geoff
-
-